import { Component, OnInit } from '@angular/core';
import { FormBuilder, Validators } from '@angular/forms';
import { passwordMatcher } from '../../utils/validators/passwordMatcher';

@Component({
  selector: 'app-user-register',
  templateUrl: './user-register.component.html',
  styleUrls: ['../user.component.scss']
})
export class UserRegisterComponent implements OnInit {

  public registForm = this.fb.group({
    userName: ['', [Validators.required]],
    email: ['', [Validators.required, Validators.email]],
    passGroup: this.fb.group({
      password: ['', [Validators.required, Validators.minLength(8)]],
      confirmPass: ['', [Validators.required]]
    }, { validator: passwordMatcher })
  });

  constructor(
    private fb: FormBuilder
  ) { }

  ngOnInit() {
  }

  doRegister() {
    console.info(this.registForm.value);
    this.toLogin();
  }

  toLogin() {
    window.history.back();
  }


}
